package com.heima.comment.controller;

import com.heima.comment.service.CommentService;
import com.heima.model.common.dtos.comment.CommentDto;
import com.heima.model.common.dtos.comment.CommentLikeDto;
import com.heima.model.common.dtos.comment.CommentSaveDto;
import com.heima.model.common.dtos.common.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.xml.stream.events.Comment;

@RestController
@RequestMapping("/api/v1/comment")
public class CommentController {
    @Autowired
    private CommentService commentService;

    /**
     * 保存评论功能
     * @param commentSaveDto
     * @return
     */
    @PostMapping("/save")
    public ResponseResult saveComment(@RequestBody CommentSaveDto commentSaveDto) {
        return commentService.save(commentSaveDto);
    }
    /**
     * 分页显示文字评论内容
     */
    @PostMapping("/load")
    public ResponseResult loadComment(@RequestBody CommentDto commentDto) {
        return commentService.load(commentDto);
    }
    @PostMapping("/like")
    public ResponseResult likeComment(@RequestBody CommentLikeDto commentLikeDto) {
        return commentService.like(commentLikeDto);
    }
}
